const LIMITS = {
  HALF: 4,
  FULL: 7,
};

export default function (
  data,
  halfHourLimit = LIMITS.HALF,
  fullHourLimit = LIMITS.FULL
) {
  let seriesData = new Array();
  for (let i = 0; i < data.length; i++) {
    // 计算半小时及1小时天波
    let halfHourValue = data[i].details["ZUTF_DEP_BOKIR"]
      ? data[i].details["ZUTF_DEP_BOKIR"]
      : 0;
    let fullHourValueAfter =
      halfHourValue +
      (i < data.length - 1 && data[i + 1].details["ZUTF_DEP_BOKIR"]
        ? data[i + 1].details["ZUTF_DEP_BOKIR"]
        : 0);
    let fullHourValueBefore =
      halfHourValue +
      (i > 0 && data[i - 1].details["ZUTF_DEP_BOKIR"]
        ? data[i - 1].details["ZUTF_DEP_BOKIR"]
        : 0);
    let fullHourValue = Math.max(fullHourValueAfter, fullHourValueBefore);
    seriesData.push({
      value:
        halfHourValue >= halfHourLimit || fullHourValue >= fullHourLimit
          ? 1
          : 0,
      halfHourException: halfHourValue >= halfHourLimit,
      fullHourException: fullHourValue >= fullHourLimit,
      halfHourValue,
      fullHourValue,
    });
  }
  return seriesData;
}
